package com.autoTools.view;

import java.awt.Label;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import com.autoTools.util.LogUtil;

public class TableView extends BaseView
{
	private JTable mTable = null;
	private JScrollPane mJScrollPane = null;
	private DefaultTableModel tableModel = null;
	public TableView()
	{

//		mTable = new JTable(model);
		
		mTable = new JTable();
		tableModel = (DefaultTableModel) mTable.getModel();
		mJScrollPane = new JScrollPane(mTable);
		mTable.setEnabled(true);
		mTable.setVisible(true);
		mTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
		BaseInit(mJScrollPane);
	}
	
	public JTable getTable(){
		return mTable;
	}
	
	public boolean addChild(BaseView child)
	{
		boolean state = false;
		if (child != null)
		{
			LogUtil.sysLog(TAG,"addChild Error:JTable is can't add child");
		}
		return state;
	}

	public void addItem(Object ...child)
	{
		super.addItem(child);
		if (child != null)
		{
			if(child instanceof Object[]){
				DefaultTableModel tableModel = (DefaultTableModel) mTable.getModel();
				tableModel.addRow((Object[])child);
			}
		}
	}

	public void removeItem(Object child)
	{
		
	}

	public void setColumn(String value){
		if(value != null){
			tableModel.addColumn(value);
		}
	}
	
	public void setLabel(String label)
	{
		super.setLabel(label);
	}
}
